package de.tabuma.pm.controller;

import de.tabuma.pm.project.controller.*;
import de.tabuma.lib.tabumacontroller;
import de.tabuma.pm.*;
import de.tabuma.pm.view.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class controller extends tabumacontroller {
    private static final Logger log = Logger.getLogger(controller.class.getName());
    public controller(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }
    @Override
    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        
        String id = request.getParameter(constants.paramAction);

        int idInt = constants.ACTION_LIST;
        if(id!=null) {
            idInt = Integer.valueOf(id).intValue();
        }

        switch(idInt) {
            case constants.ACTION_CREATE:
                create cpc = new create(this.getServlet(), this.getParameter());
                cpc.navigate(context, request, response, out);
                break;
            case constants.ACTION_REMOVE:
                remove rpc = new remove(this.getServlet(), this.getParameter());
                rpc.navigate(context, request, response, out);
                break;
            case constants.ACTION_LIST:
                list lpc = new list(this.getServlet(), this.getParameter());
                lpc.navigate(context, request, response, out);
                break;
            case constants.ACTION_OVERVIEW:
                de.tabuma.pm.project.controller.controller pov = new de.tabuma.pm.project.controller.controller(this.getServlet(), this.getParameter());
                pov.navigate(context, request, response, out);
                break;
        }
        
        view view = new view(this.getServlet(), this.getParameter());
        view.processRequest(context, request, response, out);
    }
}